package org.cttic.visualization.visualization.controller;

import cn.hutool.json.JSONObject;
import org.cttic.visualization.visualization.common.TravelTransRequest;
import org.cttic.visualization.visualization.util.ResponseObject;
import org.cttic.visualization.visualization.z_service.AssistChargingCollectService;
import org.cttic.visualization.visualization.z_service.MarkTriggerTopService;
import org.cttic.visualization.visualization.z_service.TransProvincialStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class FirstPageCollectController2 {


    @Autowired
    private AssistChargingCollectService assistChargingCollectServer;

    @Autowired
    private MarkTriggerTopService markTriggerTopService;

    @Autowired
    private TransProvincialStatisticsService transProvincialStatisticsService;

    /**
     * 2.1.3	辅助计费汇总统计查询
     *
     * @param json
     * @return
     */
    @RequestMapping("api/assistCharging/collect")
    public ResponseObject assistChargingCollect(@RequestBody JSONObject json) {

        return assistChargingCollectServer.collectStatistics(json);
    }

    /**
     * 2.1.4	识别点通行排名统计查询
     *
     * @param json
     * @return
     */
    @RequestMapping("api/markTrigger/top")
    public ResponseObject markTriggerTop(@RequestBody JSONObject json) {
        return markTriggerTopService.triggerTop(json);
    }


    /**
     * 2.1.5	跨省车辆汇总统计查询
     *
     * @return
     */
    @RequestMapping("api/transProvincial/statics")
    public ResponseObject TransProvincialStatics(@RequestBody JSONObject json) {

        return transProvincialStatisticsService.statisticsTrans(json);

    }

    /**
     * 2.6.4	跨省迁移车辆统计查询
     */
    @RequestMapping("api/transProvincial/vehicles")
    public ResponseObject vehicleTransStatics(@RequestBody JSONObject json){
        return transProvincialStatisticsService.statisticsVehicle(json);
    }


    /**
     * 2.6.5	跨省迁移车辆路径查询
     * @param travelTransRequest
     * @return
     */
    @RequestMapping("api/transProvincial/travel")
    public ResponseObject travelTransStatics(@RequestBody TravelTransRequest travelTransRequest, BindingResult binding){
        if(binding.hasErrors()){
            return ResponseObject.error(binding.getFieldError().getDefaultMessage());
        }

        return transProvincialStatisticsService.statisticsTravel(travelTransRequest);
    }



}
